import 'package:boss/models/takeout_order_list_data.dart' as model;
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/page/takeoutManagement/constant/takeout_status.dart';
import 'package:boss/ui/page/takeoutManagement/page/takeoutList/widget/delivery_message.dart';
import 'package:boss/ui/page/takeoutManagement/page/takeoutList/widget/order_message.dart';
import 'package:boss/ui/page/takeoutManagement/page/takeoutList/widget/orderer_message.dart';
import 'package:boss/ui/page/takeoutManagement/page/takeoutProcess/widget/timer_text.dart';
import 'package:boss/ui/page/takeoutManagement/page/widget/takeout_button_group.dart';
import 'package:boss/ui/widget/custom_divier.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

import 'add_timer_text.dart';
import 'estimated_deliveryed_time.dart';

class TakeoutOrderItem extends StatelessWidget {
  final model.TakeoutOrderItem data;

  TakeoutOrderItem({Key key, @required this.data}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTextStyle(
      style: TextStyleConstant().normal_1_28,
      child: ShadowRadiusCard(
        margin: EdgeInsets.symmetric(
          horizontal: 30.w,
          vertical: 15.w,
        ),
        padding: EdgeInsets.symmetric(
          horizontal: 30.w,
          vertical: 15.w,
        ),
        child: Column(
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Text(
                      '${data.takeNo}${data.type == TakeoutStatus.SELF_PICK ? '(自取)' : ''}',
                      style: TextStyleConstant().normal_1_36,
                    ),
                    EstimatedDeliveryedTime(
                      data: data,
                    ),
                  ],
                ),
                Row(
                  children: <Widget>[
                    Text(data.statusName),
                  ],
                ),
              ],
            ),
            if ([
              TakeoutStatus.TAKE_PICKUP,
              TakeoutStatus.WAIT_PICKUP,
            ].contains(data.systemOrderStatus))
              AddTimerText(
                title: '备餐时间',
                dateTime: data.ctime,
              ),
            if (TakeoutStatus.ABNORMA_ORDER == data.systemOrderStatus)
              TimerText(title: '剩余时长', dateTime: data.ctime, duration: Duration(hours: 24), timerType: TimerType.h_m,),
            OrdererMessage(
              data: data,
            ),
            CustomDivider(
              margin: EdgeInsets.symmetric(
                vertical: 15.w,
              ),
            ),
            OrderMessage(
              data: data,
            ),
            DeliverMessage(
              data: data,
            ),
            if ([
              TakeoutStatus.NEW_ORDER,
              TakeoutStatus.TAKE_PICKUP,
              TakeoutStatus.COMPLETED,
              TakeoutStatus.WAIT_PICKUP,
              TakeoutStatus.ABNORMA_ORDER,
              TakeoutStatus.REBACK_ORDER,
            ].contains(data.systemOrderStatus))
              CustomDivider(
                margin: EdgeInsets.symmetric(
                  vertical: 15.w,
                ),
              ),
            TakeoutButtonGroup(
              data: data,
            ),
          ],
        ),
      ),
    );
  }
}
